package com.mDigitalHealth.http;

import java.util.LinkedHashMap;
import java.util.Map;

import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;

public class DigitalHealthFetchUserInfoResponse {
	private String _Transaction_Id;
	private String _Login_Name;
	private String _User_Number;
	private int _Fetch_Status;
	private int _User_Gender;
	private int _User_Height;
	private int _User_Weight;
	private int _Step_Length;
	private int _Run_Step_Length;
	private int _Day_Plan_Step_Count;

	public DigitalHealthFetchUserInfoResponse() {
		this._Transaction_Id = "";
		this._Login_Name = "";
		this._User_Number = "";
		this._Fetch_Status = -1;
		this._User_Gender = 0;
		this._User_Height = 0;
		this._User_Height = 0;
		this._Step_Length = 0;
		this._Run_Step_Length = 0;
		this._Day_Plan_Step_Count = 0;
	}

	public DigitalHealthFetchUserInfoResponse(String strTransactionId, String strLoginName,
			String strUserNumber, int nFetchStatus, int nUserGender, int nUserHeight,
			int nUserWeight, int nStepLength, int nRunStepLength, int nDayPlanStepCount) {
		this._Transaction_Id = strTransactionId;
		this._Login_Name = strLoginName;
		this._User_Number = strUserNumber;
		this._Fetch_Status = nFetchStatus;
		this._User_Gender = nUserGender;
		this._User_Height = nUserHeight;
		this._User_Weight = nUserWeight;
		this._Step_Length = nStepLength;
		this._Run_Step_Length = nRunStepLength;
		this._Day_Plan_Step_Count = nDayPlanStepCount;
	}

	public void setTransactionId(String strTransactionId) {
		this._Transaction_Id = strTransactionId;
	}

	public String getTransactionId() {
		return this._Transaction_Id;
	}

	public void setLoginName(String strLoginName) {
		this._Login_Name = strLoginName;
	}

	public String getLoginName() {
		return this._Login_Name;
	}

	public void setUserNumber(String strUserNumber) {
		this._User_Number = strUserNumber;
	}

	public String getUserNumber() {
		return this._User_Number;
	}

	public void setFetchStatus(int nFetchStatus) {
		this._Fetch_Status = nFetchStatus;
	}

	public int getFetchStatus() {
		return this._Fetch_Status;
	}

	public void setUserGender(int nUserGender) {
		this._User_Gender = nUserGender;
	}

	public int getUserGender() {
		return this._User_Gender;
	}

	public void setUserHeight(int nUserHeight) {
		this._User_Height = nUserHeight;
	}

	public int getUserHeight() {
		return this._User_Height;
	}

	public void setUserWeight(int nUserWeight) {
		this._User_Weight = nUserWeight;
	}

	public int getUserWeight() {
		return this._User_Weight;
	}

	public void setStepLength(int nStepLength) {
		this._Step_Length = nStepLength;
	}

	public int getStepLength() {
		return this._Step_Length;
	}

	public void setRunStepLength(int nRunStepLength) {
		this._Run_Step_Length = nRunStepLength;
	}

	public int getRunStepLength() {
		return this._Run_Step_Length;
	}

	public void setDayPlanStepCount(int nDayPlanStepCount) {
		this._Day_Plan_Step_Count = nDayPlanStepCount;
	}

	public int getDayPlanStepCount() {
		return this._Day_Plan_Step_Count;
	}

	public String encode() {
		try {
			LinkedHashMap map = new LinkedHashMap();

			map.put("Transaction_Id", this._Transaction_Id);
			map.put("Login_Name", this._Login_Name);
			map.put("User_Number", this._User_Number);
			map.put("Fetch_Status", Integer.valueOf(this._Fetch_Status));
			map.put("User_Gender", Integer.valueOf(this._User_Gender));
			map.put("User_Height", Integer.valueOf(this._User_Height));
			map.put("User_Weight", Integer.valueOf(this._User_Weight));
			map.put("Step_Length", Integer.valueOf(this._Step_Length));
			map.put("Run_Step_Length", Integer.valueOf(this._Run_Step_Length));
			map.put("Day_Plan_Step_Count", Integer.valueOf(this._Day_Plan_Step_Count));

			return JSONValue.toJSONString(map);
		} catch (Exception e) {
		}
		return null;
	}

	public int decode(String strCode) {
		try {
			if (strCode == null) {
				return -1;
			}
			JSONParser parser = new JSONParser();
			Map map = (Map) parser.parse(strCode);
			this._Transaction_Id = ((String) map.get("Transaction_Id"));
			this._Login_Name = ((String) map.get("Login_Name"));
			this._User_Number = ((String) map.get("User_Number"));
			this._Fetch_Status = Integer.parseInt(map.get("Fetch_Status").toString());
			this._User_Gender = Integer.parseInt(map.get("User_Gender").toString());
			this._User_Height = Integer.parseInt(map.get("User_Height").toString());
			this._User_Weight = Integer.parseInt(map.get("User_Weight").toString());
			this._Step_Length = Integer.parseInt(map.get("Step_Length").toString());
			this._Run_Step_Length = Integer.parseInt(map.get("Run_Step_Length").toString());
			this._Day_Plan_Step_Count = Integer.parseInt(map.get("Day_Plan_Step_Count").toString());

			return 1;
		} catch (Exception e) {
		}
		return -1;
	}
}
